package cn.shiwei.hr.web.controller;

import cn.shiwei.hr.dto.SMSCodeDto;
import cn.shiwei.hr.repository.AjaxResult;
import cn.shiwei.hr.service.IVerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class VerifyController {

    @Autowired
    private IVerifyService verifyService;

    @GetMapping("/imageCode/{imageKey}")
    public AjaxResult getImageCode(@PathVariable("imageKey") String imageKey){
        return AjaxResult.me().setResultObj(verifyService.getImageCode(imageKey));
    }

    @PostMapping("sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody @Valid SMSCodeDto smsCodeDto){
        verifyService.sendSmsCode(smsCodeDto);
        return AjaxResult.me();
    }
}
